﻿using AutoMapper;
using BLL.Interface;
using BLL.Model;
using DAL.Engine.Domain;
using DAL.Engine.Interface;
using System;
using System.Collections.Generic;
using System.Linq;

namespace BLL.Service
{
    public class UserService : IUserService
    {
        IUserRepository _userRepository;
        IEntityMapper _mapper;

        public UserService(IUserRepository userRepository, IEntityMapper mapper)
        {
            _userRepository = userRepository;
            _mapper = mapper;
        }

        public IEnumerable<UserModel> GetUsers()
        {
            var existingUsers = _userRepository.GetAll();
            var userModels = _mapper.Map<IEnumerable<User>, IEnumerable<UserModel>>(existingUsers);
            return userModels;
        }
    }
}
